package demo.using;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;

import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author : GuoFei
 * @date : 2018/12/4 14:50
 */
public class MyJSONObject<T> extends JSONObject{
    public MyJSONObject put(String key, Object val){
        super.put(key, val);
        return this;
    }

    public static void main(String[] args) {
//        JSONArray items = JSONArray.parseArray("[{\"id\":1,\"test\":2,\"videoName\":\"srK\"},{\"videoId\":1,\"id\":2,\"videoName\":\"WSk\"},{\"videoId\":2,\"id\":3,\"test\":2,\"videoName\":\"VbK\"},{\"videoId\":2,\"id\":4,\"test\":2,\"videoName\":\"lfj\"},{\"videoId\":1,\"id\":5,\"videoName\":\"QwW\"},{\"videoId\":2,\"id\":6,\"videoName\":\"gAs\"}]\n");
//
////        Map<Integer, JSONObject> dataMaps = Maps.newLinkedHashMap();
//        Map<Integer, JSONObject> dataMaps = new HashMap<>();
//
//        for (Object i : items) {
//            JSONObject item = (JSONObject) i;
//
//            item.computeIfAbsent("test", k ->new JSONArray());
//        }
//
////        List<JSONObject> results = Lists.newArrayList();
////        dataMaps.forEach((k, v) -> results.add(v));
//        System.out.println(items);

        String tt = URLDecoder.decode("data=%7B%22userLog%22%3A%5B%7B%22questionId%22%3A%222149544%22%2C%22answer%22%3A%229378966%22%2C%22isTrue%22%3A1%2C%22time%22%3A%222018%2F12%2F17+17%3A28%3A22%22%7D%2C%7B%22questionId%22%3A%222150829%22%2C%22answer%22%3A%229385400%22%2C%22isTrue%22%3A0%2C%22time%22%3A%222018%2F12%2F17+17%3A28%3A22%22%7D%2C%7B%22questionId%22%3A%222151681%22%2C%22answer%22%3A%229389664%22%2C%22isTrue%22%3A0%2C%22time%22%3A%222018%2F12%2F17+17%3A28%3A22%22%7D%2C%7B%22questionId%22%3A%222151684%22%2C%22answer%22%3A%229389675%22%2C%22isTrue%22%3A1%2C%22time%22%3A%222018%2F12%2F17+17%3A28%3A22%22%7D%2C%7B%22questionId%22%3A%222151747%22%2C%22answer%22%3A%229389994%22%2C%22isTrue%22%3A1%2C%22time%22%3A%222018%2F12%2F17+17%3A28%3A22%22%7D%2C%7B%22questionId%22%3A%222152769%22%2C%22answer%22%3A%229395105%22%2C%22isTrue%22%3A1%2C%22time%22%3A%222018%2F12%2F17+17%3A28%3A22%22%7D%2C%7B%22questionId%22%3A%222153102%22%2C%22answer%22%3A%229396769%22%2C%22isTrue%22%3A1%2C%22time%22%3A%222018%2F12%2F17+17%3A28%3A22%22%7D%2C%7B%22questionId%22%3A%222153547%22%2C%22answer%22%3A%229399002%22%2C%22isTrue%22%3A1%2C%22time%22%3A%222018%2F12%2F17+17%3A28%3A22%22%7D%2C%7B%22questionId%22%3A%222155627%22%2C%22answer%22%3A%229408916%22%2C%22isTrue%22%3A1%2C%22time%22%3A%222018%2F12%2F17+17%3A28%3A22%22%7D%2C%7B%22questionId%22%3A%222155629%22%2C%22answer%22%3A%229408927%22%2C%22isTrue%22%3A1%2C%22time%22%3A%222018%2F12%2F17+17%3A28%3A22%22%7D%2C%7B%22questionId%22%3A%222155632%22%2C%22answer%22%3A%229408944%22%2C%22isTrue%22%3A1%2C%22time%22%3A%222018%2F12%2F17+17%3A28%3A22%22%7D%2C%7B%22questionId%22%3A%222155634%22%2C%22answer%22%3A%229408951%22%2C%22isTrue%22%3A1%2C%22time%22%3A%222018%2F12%2F17+17%3A28%3A22%22%7D%2C%7B%22questionId%22%3A%222155636%22%2C%22answer%22%3A%229408964%22%2C%22isTrue%22%3A1%2C%22time%22%3A%222018%2F12%2F17+17%3A28%3A22%22%7D%2C%7B%22questionId%22%3A%222155639%22%2C%22answer%22%3A%229408978%22%2C%22isTrue%22%3A1%2C%22time%22%3A%222018%2F12%2F17+17%3A28%3A22%22%7D%2C%7B%22questionId%22%3A%222155641%22%2C%22answer%22%3A%229408987%22%2C%22isTrue%22%3A1%2C%22time%22%3A%222018%2F12%2F17+17%3A28%3A22%22%7D%2C%7B%22questionId%22%3A%222155643%22%2C%22answer%22%3A%229408998%22%2C%22isTrue%22%3A1%2C%22time%22%3A%222018%2F12%2F17+17%3A28%3A22%22%7D%2C%7B%22questionId%22%3A%222155644%22%2C%22answer%22%3A%229409000%22%2C%22isTrue%22%3A1%2C%22time%22%3A%222018%2F12%2F17+17%3A28%3A22%22%7D%2C%7B%22questionId%22%3A%222160264%22%2C%22answer%22%3A%229432141%22%2C%22isTrue%22%3A1%2C%22time%22%3A%222018%2F12%2F17+17%3A28%3A22%22%7D%2C%7B%22questionId%22%3A%222161152%22%2C%22answer%22%3A%229436589%22%2C%22isTrue%22%3A1%2C%22time%22%3A%222018%2F12%2F17+17%3A28%3A22%22%7D%2C%7B%22questionId%22%3A%222823098%22%2C%22answer%22%3A%2212696204%22%2C%22isTrue%22%3A1%2C%22time%22%3A%222018%2F12%2F17+17%3A28%3A22%22%7D%5D%2C%22planItemId%22%3A%22448%22%2C%22questionCount%22%3A20%7D&trueCount=18&justOnePass=");
        System.out.println(tt);
    }
}
